home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Tools & Apps / Testing & Debugging / Robix V1.0 / JG_prolog.a < prev    next >
Encoding:
Text File  |  1991-08-21  |  3.0 KB  |  92 lines  |  [TEXT/MPS ]

  1. ;
  2. ;
  3. ; Copyright © 1991, Apple Computer, Inc.
  4. ;
  5. ; by Rob Glanville
  6. ;
  7. ; 15 May 91
  8. ;
  9. ; JG_prolog.a - Startup assembly code
  10. ;
  11. ;
  12. ; Memory Map - 512kb assumed
  13. ; 00000000 - 000003FF = Interrupt Vectors
  14. ; 00000400 - 000005FF = Command buffer
  15. ; 00000600 - 00007FFF = Stack
  16. ; 00008000 - 0000FFFF = Data
  17. ; 00010000 - 00017FFF = Code
  18. ; 00018000 - 0007FFFF = Free memory
  19. ; 00080000 - 00FFFFFF = Memory mapped I/O
  20. ;
  21. ; Since this code is linked in with the application that uses it, the
  22. ; A5 data reference changes every time variables are added or subtracted.
  23. ; To pin down the data for this code, A5 is adjusted so the top of the
  24. ; data is always at 10000. It's tricky so don't fool with it!
  25. ; The main purpose of this code is to provide a stable environment for
  26. ; the C code to start with. All the real work should be done in C.
  27. ; Try not to modify this code if possible, it is just a bridge.
  28. ; How this works;
  29. ; 1) The stack and data reference registers are initialized
  30. ; 2) The data segment is cleared
  31. ; 3) A key word is used to signal the Mac we're ready to go
  32. ; 4) We wait for a test command before jumping to the C code
  33.  
  34. TOS        equ    $18000        ; Top of stack
  35. TOD        equ    $fffe        ; Top of Data
  36. ClearCount    equ    $3FE        ; Clear this many 32 bit words
  37. VectorCount    equ    $fe        ; Number of vector pointers
  38. Null        equ    $00000000    ; Zero
  39. InitialSR    equ    $2700        ; Initial status register
  40. ClearStart    equ    $00000008    ; After the reset vector
  41. Pattern        equ    $00000000    ; Clear memory pattern
  42. GreenLight    equ    $00500000    ; Green light control
  43. RedLight    equ    $00400000    ; Green light control
  44. SmartMode    equ    $00600000    ; Smart mode control
  45.  
  46.     import    COMMANDLOOP
  47.  
  48. Begin    proc    export
  49.     data
  50.     import    TopOfData        ; First variable in C code
  51.     code
  52.     move.w    #InitialSR,sr        ; Clear interrupts
  53.     move.l    #TOS,sp            ; Set up the stack pointer
  54.     move.b    $CA000C,d0        ; Reset and clear
  55.     move.b    $CA0008,d0        ; Reset and clear
  56.     move.b    $C00004,d0        ; Reset and clear
  57.     move.b    $C00002,d0        ; Reset and clear
  58.     move.b    #$00,$CA000D        ; Reset and clear
  59.     move.b    #$87,$CA000F        ; Reset and clear
  60.     move.w    #$0000,$CA0008        ; Reset DMA control register
  61.     move.w    SmartMode,d0        ; Select smart mode
  62.     move.w    RedLight,d0        ; Turn on red light
  63.     move.w    d0,GreenLight        ; Turn off green light
  64.     move.l    #TOD,d0            ; Set up data pointer
  65.     move.l    #Null,a5        ; Set up data pointer
  66.     lea    TopOfData,a0        ; Get address
  67.     move.l    a0,d1            ; Copy
  68.     sub.l    d1,d0            ; Adjust
  69.     move.l    d0,a5            ; Set the data offset
  70.     move.l    #ClearCount,d0        ; Set data size
  71.     move.l    #ClearStart,a0        ; Clear pointer
  72. clear    move.l    #Pattern,(a0)+        ; Zap memory
  73.     dbra    d0,clear        ; Loop back until done
  74.     lea    UnusedInterrupt,a1    ; Get the pointer
  75.     move.l    #VectorCount,d0        ; Set vector count
  76.     move.l    #ClearStart,a0        ; Clear pointer
  77. Zap    move.l    a1,(a0)+        ; Zap memory
  78.     dbra    d0,Zap            ; Loop back until done
  79.     move.w    GreenLight,d0        ; Turn on green light
  80.     move.w    d0,RedLight        ; Turn off red light
  81.     bra.w    COMMANDLOOP        ; Enter the C code
  82.     bra.w    Begin            ; Start over if we ever return
  83.  
  84. UnusedInterrupt
  85.     move.l    #'Int0',$0        ; Set the error flag
  86.     rte                ; Interrupt return
  87.     
  88.     endp                ; End of procedure
  89.     end                ; End of source
  90.  
  91.